﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

namespace SLUISystem
{
    public class EditorZoomArea
    {
        private static Matrix4x4 _prevGuiMatrix;

        public static void Begin(Rect screenCoordsArea, float zoomScale)
        {
            Rect rect = screenCoordsArea;
            rect.y = (rect.y + EditorWindowConfig.EditorWindowTabHeight);
            GUI.BeginGroup(rect);
            _prevGuiMatrix = GUI.matrix;
            Matrix4x4 matrix4x = Matrix4x4.TRS(new Vector2(rect.xMin, rect.yMin), Quaternion.identity, Vector3.one);
            Matrix4x4 matrix4x2 = Matrix4x4.Scale(new Vector3(zoomScale, zoomScale, 1f));
            GUI.matrix = (matrix4x * matrix4x2 * matrix4x.inverse * GUI.matrix);
        }


        public static void End()
        {
            GUI.EndGroup();
        }

    }
}
